package vip.xiaonuo.smzq.modular.kcl.controller;

import javax.annotation.Resource;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import vip.xiaonuo.smzq.modular.kcl.entity.Dztj;
import vip.xiaonuo.smzq.modular.kcl.service.IDztjService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.validation.annotation.Validated;
import vip.xiaonuo.common.pojo.CommonResult;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;


/**
 * 地质条件
 *
 * @author eomer
 * @since 2024-02-22
 */
@Api(tags = "地质条件")
@RestController
@RequestMapping("/kcl/dztj")
@Validated
public class DztjController {

    @Resource
    private IDztjService iDztjService;

    /**
     * 添加地质条件
     */
    @ApiOperation("添加地质条件")
    @PostMapping("/add")
    public CommonResult<String> add(@RequestBody @Valid Dztj dztj) {
        iDztjService.save(dztj);
        return CommonResult.ok();
    }

    /**
     * 删除地质条件
     */
    @ApiOperation("删除地质条件")
    @PostMapping("/delete")
    public CommonResult<String> delete(@ApiParam(name = "pkid", value = "主键") @RequestParam String pkid) {
        iDztjService.removeById(pkid);
        return CommonResult.ok();
    }

    /**
     * 编辑地质条件
     */
    @ApiOperation("编辑地质条件")
    @PostMapping("/edit")
    public CommonResult<String> edit(@RequestBody @Valid Dztj dztj) {
        iDztjService.updateById(dztj);
        return CommonResult.ok();
    }

    /**
     * 地质条件分页查询
     */
    @ApiOperation("地质条件分页查询")
    @GetMapping("/list")
    public CommonResult<Page<Dztj>> page() {
        return CommonResult.data(iDztjService.page(new Dztj()));
    }
    /**
     * 地质条件分页查询
     */
    @ApiOperation("地质条件分页查询")
    @GetMapping("/getDztj")
    public CommonResult<Dztj> getDztj(
            @ApiParam(name = "kqbm", value = "矿区编码", required = true) @RequestParam String kqbm,
            @ApiParam(name = "djflbm", value = "登记分类编码", required = true) @RequestParam Integer djflbm,
            @ApiParam(name = "nd", value = "年度", required = true) @RequestParam Integer nd
    ) {
        return CommonResult.data(iDztjService.getDztj(kqbm, djflbm, nd));
    }
}
